function cityIniti(url,pid,cid,rid){
    var areahtml = '';
    var url = url ? url:''
    var pid = pid ? pid: 0;
    var cid = cid ? cid: 0;
    var rid = rid ? rid: 0;

    $.each(areaList,function(k1,v1){
        var url1 = url ? url:'javascript:void(0)';
        areahtml += '<li class="plevel"><div><em class="leve_2" data-level="1"></em><span class="folder-open"></span><a href="'+url1+'">'+v1['topic']+'</a></div>';

        if(v1.childs && v1.childs.length){

            areahtml += '<ul class="ul_level_1" style="display:'+(pid==v1['Id']?'block':'none')+'">';

            $.each(v1.childs,function(k2,v2){

                var url2 = url ? url+"?pa="+v2['Id']:'javascript:void(0)';

                areahtml += '<li><div><em class="leve_'+(cid==v2['Id']?2:1)+'" data-level="2"></em><span class="folder'+(cid==v2['Id']?'-open':'')+'"></span><a href="'+url2+'">'+v2['topic']+'</a></div>';

                if(v2.childs && v2.childs.length){

                    areahtml += '<ul class="ul_level_2" style="display:'+(cid==v2['Id']?'block':'none')+'">';
                    $.each(v2.childs,function(k3,v3){
                        var url3 = url ? url+"?pa="+v2['Id']+'&pb='+v3['Id']:'javascript:void(0)';
                        areahtml += '<li><div><em class="last"></em><span class="folder-last"></span><a href="'+url3+'" class="'+(rid==v3['Id']?'hover':'')+'">'+v3['topic']+'</a></div></li>';
                    })

                    areahtml += '</ul>';
                }

                areahtml += '</li>';
            })

            areahtml += '</ul>';
        }
        areahtml + '</li>';
    })
    $('.menutree ul').html(areahtml);
}




function cityIniti2(url,pid,cid,rid){
    var areahtml = '';
    var url = url ? url:''
    var pid = pid ? pid: 0;
    var cid = cid ? cid: 0;
    $.each(areaList,function(k1,v1){
        areahtml += '<li class="plevel"><div><em class="leve_2" data-level="1"></em><span class="folder-open"></span><a href="javascript:void(0)">'+v1['topic']+'</a></div>';
        if(v1.childs && v1.childs.length){
            areahtml += '<ul class="ul_level_1" style="display:block">';
            $.each(v1.childs,function(k2,v2){
                var url1 = url ? url+"?pa="+v2['Id']:'javascript:void(0)';
                areahtml += '<li><div><em class="last"></em><span class="folder-last"></span><a href="'+url1+'" class="'+(cid==v2['Id']?'hover':'')+'">'+v2['topic']+'</a></div>';

                areahtml += '</li>';
            })
            areahtml += '</ul>';
        }
        areahtml + '</li>';
    })
    $('.menutree ul').html(areahtml);
}

$(document).ready(function(e) {
    $('.menutree').on("click",".leve_2,.leve_1",function(){
        var level_val = $(this).data('level');
        if($(this).hasClass('leve_2')){
            $(this).parent().find('span').removeClass('folder-open').addClass('folder');
            $(this).removeClass('leve_2').addClass('leve_1');
            $(this).parent().parent().find('.ul_level_'+level_val).slideUp(200);
        }else{
            $(this).parent().find('span').removeClass('folder').addClass('folder-open');
            $(this).removeClass('leve_1').addClass('leve_2');
            $(this).parent().parent().find('.ul_level_'+level_val).slideDown(200);
        }
    });
});